package com.code.pattern.delegate;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 委派模式
 * 项目经理 Leader 类
 * @author lyf
 * @date 2021-03-23 上午10:23
 */
public class Leader implements IEmployee {

    private Map<String, IEmployee> targets = Maps.newHashMap();

    public Leader() {
        targets.put("加密", new EmployeeA());
        targets.put("登录", new EmployeeB());
    }

    @Override
    public void doing(String command) {
        // 选择对应员工做事
        targets.get(command).doing(command);
    }
}
